<%@ page language="java" import="pos.domain.*,java.util.*" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>


<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Estado de valoracion</title>
<style type="text/css">
body {
    background-color:#4F4F4F
    
    
    
}
div {
    background-color:#CD5A24;
    margin-right:300px;
    margin-left: 200px;
    color: #333;
}
</style>
</head>
<body>
<img src= "http://www.thepropertyexchange.com.au/images/prop-header.png" />
<%
IRatingManager rm=new RatingManager();
String message="";
IExchangeManager em= new ExchangeManager();
String eid=request.getParameter("eid");
Exchange e= em.dameUno(eid);
String user=(String)session.getAttribute("session.user");

String userRat=e.getEmailSent();
String property=e.getPropertySentID();
if(e.getEmailSent().equals(user)){
    userRat=e.getEmailReceived();
    property=e.getPropertyReceivedID();
}

String exchangeID=e.getExchangeID();



String geoLoc=request.getParameter("geoLocation");    
String cle=request.getParameter("cleaning");
String cont=request.getParameter("contracted");
String comPro=request.getParameter("comments");

String cal=request.getParameter("calification");
String comU=request.getParameter("commentsUser");


if(exchangeID!=null){
    PropertyRating pr=new PropertyRating();
    pr.setExchangeID(exchangeID);
    pr.setPropertyID(property);
    pr.setGeographicalLocation(Integer.parseInt(geoLoc));
    pr.setCleaning(Integer.parseInt(cle));
    pr.setContracted(Integer.parseInt(cont));
    pr.setComments(comPro);
    
    
    UserRating ur=new UserRating();
    ur.setEmail(userRat);
    ur.setCalification(Float.parseFloat(cal));
    ur.setComments(comU);
    
    
    rm.realizarValoracion(pr,ur);
    
    message=new String("VALORACION GUARDADA, GRACIAS");
    
}else{
    message=new String("FALTA ALGUN CAMPO POR RELLENAR");

}
%>
<h6><%=message %></h6>
<a href="FrontController?res=Perfil.jsp">volver</a>
</body>
</html> 